Skip to content

fix(tool): tolerate stringified nested-union tool arguments - #298

Merged
LeXwDeX merged 1 commit into
devfrom
fix/tool-union-params
Aug 16, 2026
Merged

fix(tool): tolerate stringified nested-union tool arguments#298
LeXwDeX merged 1 commit into
devfrom
fix/tool-union-params

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Closes #297

Summary

qwen-family models string-encode tool-argument containers whose schema is a nested union ({"params": "{\"action\": \"list\"}"}), making the workflow tool completely unusable on those models. Verified end-to-end: opencode's schema generation and parse pipeline are innocent; the wire capture shows the model emitting the double-encoded string; controlled A/B proves only the union shape on qwen triggers it.

Change

  • tool.ts: strict decode first; on failure only, a lenient retry re-parses string values that sit where a container is expected (repairStringifiedContainers), then lets the normal decode judge the result. Legitimate strings are never touched because the retry only runs after strict decoding failed.
  • Quirk-family documentation comment extended with the qwen case.

Verification

  • 3 new unit tests in test/tool/tool-define.test.ts (repair round-trip, unrepairable still rejects, JSON-looking plain strings untouched); suite 9/9.
  • bun typecheck clean from packages/opencode.

Merge note

Precondition for the DAG dogfood path (issues #293/#294/#296 follow-ups): the running binary needs rebuild + restart before the workflow tool works on qwen-family models. Suggest merging this first among the harness batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant